import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/global.css'
import './assets/fonts/iconfont.css'
import axios from 'axios'
import ZkTable from 'vue-table-with-tree-grid'
import VueQuillEditor from 'vue-quill-editor'
// require styles
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'
Vue.use(VueQuillEditor)

Vue.component('tree-table', ZkTable)

axios.defaults.baseURL = 'http://liufusong.top:8888/api/private/v1/'

// 添加拦截器
axios.interceptors.request.use(config => {
  // console.log(config.url)
  if (config.url !== 'login') {
    config.headers.Authorization = sessionStorage.getItem('token')
  }
  return config
})

Vue.prototype.$axios = axios
Vue.config.productionTip = false
// 定义时间过滤器
Vue.filter('formatDate', (date) => {
  const dateobj = new Date(date * 1000)
  const y = dateobj.getFullYear()
  const m = (dateobj.getMonth() + 1).toString().padStart(2, '0')
  const d = dateobj.getDate().toString().padStart(2, '0')
  return `${y}-${m}-${d}`
})

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
